package chain;

public abstract class ExceptionHandler {
    protected ExceptionHandler nextHandler;

    public ExceptionHandler setNext(ExceptionHandler handler) {
        this.nextHandler = handler;
        return handler;
    }

    public abstract void handle(SystemException exception);

    protected void passToNext(SystemException exception) {
        if (nextHandler != null) {
            nextHandler.handle(exception);
        } else {
            System.out.println("无法处理的异常: " + exception.getDescription());
        }
    }
}
